import { createRouter, createWebHashHistory } from "vue-router";
// import Home from "../views/Home.vue";
// import Vue from "vue";
// Vue.useAttrs(VueRouter);
const routes = [{
        path: "/",
        name: "Home",
        redirect: "/home",
    },
    { //主页面
        path: "/home",
        component: () =>
            import ("../views/Home.vue"),
        children: [{
                path: "/home",
                redirect: "/home/head",
            },
            { //首页
                path: "/home/head",
                component: () =>
                    import ("../components/Home-/Head.vue"),
                meta: {
                    title: '首页',
                },
            },
            { //聊天页
                path: "/home/talk",
                component: () =>
                    import ("../components/Home-/Talk.vue"),
                meta: {
                    title: '聊',
                },
            },
            { //定制页
                path: "/home/dingzhi",
                component: () =>
                    import ("../components/Home-/Dingzhi.vue"),
                meta: {
                    title: '定制',
                },
            },
            { //我的页面
                path: "/home/mine",
                component: () =>
                    import ("../components/Home-/Mine.vue"),
                meta: {
                    title: '我的',
                },
            },
        ]
    },
    { //详情页
        path: "/detail",
        component: () =>
            import ("../views/Detail.vue"),
        meta: {
            title: '商品详情',
        },
    },
    { //登入页
        path: "/login",
        component: () =>
            import ("../views/Login.vue"),
        meta: {
            title: '登录',
        },
    },
    { //注册页
        path: "/registry",
        component: () =>
            import ("../views/Registry.vue"),
        meta: {
            title: '注册',
        },
    },
    { //搜索页
        path: "/search",
        component: () =>
            import ("../components/Home-/Home-Head-/Search.vue"),
        meta: {
            title: '搜索',
        },
    },
    { //品牌库页
        path: "/pinpaiku",
        component: () =>
            import ("../components/Home-/Home-Head-/Pinpaiku.vue"),
        meta: {
            title: '品牌库',
        },
    },
    { //美妆榜页
        path: "/meizhuangbang",
        component: () =>
            import ("../components/Home-/Home-Head-/Meizhuangbang.vue"),
        meta: {
            title: '美妆榜',
        },
    },
    { //护肤榜页
        path: "/hufubang",
        component: () =>
            import ("../components/Home-/Home-Head-/Hufubang.vue"),
        meta: {
            title: '护肤榜',
        },
    },
    { //分类页
        path: "/classify",
        component: () =>
            import ("../components/Home-/Home-Talk-/Classify.vue"),
        meta: {
            title: '分类',
        },
    },
    { //图像肤质改变页
        path: "/skinchange",
        component: () =>
            import ("../components/Home-/Home-Mine-/skinChange.vue"),
        meta: {
            title: '肤质',
        },
    },
    { //图像测试页
        path: "/testimage",
        component: () =>
            import ("../components/Home-/Home-Mine-/testImage.vue"),
        meta: {
            title: '图像测试',
        },
    },
];

const router = createRouter({
    history: createWebHashHistory(),
    routes,
});

// 设置页面标题
router.beforeEach((to, form, next) => {
    document.title = to.meta.title;
    next();
});

export default router;